<template>
    <span>
        <Button type="info" size="small" @click="handleAppCheckShow(data)">审核</Button>
        <Modal v-model="app_check_modal" title="应用授权" :mask-closable="false">
            <p>是否同意 {{ app_current.app_name || app_current.app_id }} 的中继服务申请？</p>
            <template #footer>
                <Button type="primary" @click="handleAppCheck(true)">同意</Button>
                <Button type="warning" @click="handleAppCheck(false)">拒绝</Button>
            </template>
        </Modal>
    </span>
</template>

<script>
export default {
    name: 'AppCheckButton',
    props: {
        data: Object
    },
    mounted () {
    },
    methods: {
        handleAppCheckShow(row) {
            this.app_current.id = row.id;
            this.app_current.app_id = row.app_id;
            this.app_current.app_name = row.app_name;
            this.app_check_modal = true;
        },
        handleAppCheck(check_result) {
            this.$http.post('/app_check', { app_id: this.app_current.app_id, app_check: check_result ? 1 : 0 }).then(res => {
                if (res.status == 'ok') {
                    this.$Message.success('审核完成');
                    this.app_check_modal = false;
                    this.$emit('success');
                } else {
                    this.errorMessage(res.data);
                }
            })
        },
    }
}
</script>